﻿Imports DataObject
Imports BusinessObject
Imports Microsoft.ApplicationBlocks.Data

Public Class frmLoaiTienList

    Private oLoaiTien As New BusLoaiTien
    Private oPrLoaiTien As New LoaiTien
    Private oConn As New hDBase

    Private Sub frmLoaiTienList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        InitData()
        LoadGridView()
        RefreshToolbar()
    End Sub

    Protected Overrides Sub LoadDataGrid()
        Try
            tableDictionary = oLoaiTien.GetAllLoaiTien(sConn)
            ListBindingSource.DataSource = tableDictionary
            grdList.DataSource = ListBindingSource
        Catch ex As Exception
            MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

    Private Sub LoadGridView()
        Try
            grdList.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect
            With grdList.DisplayLayout.Bands(0)
                .Columns("SoLoaiTien").Hidden = True
                .Columns("ToanTuQuyDoi").Hidden = True

                .Columns("MaLoaiTien").Header.Caption = "Mã loại tiền"
                .Columns("TenLoaiTien").Header.Caption = "Tên loại tiền"
                .Columns("TyGiaQuyDoi").Header.Caption = "Tỷ giá"

                .Columns("MaLoaiTien").Width = 50
                .Columns("TenLoaiTien").Width = 100
            End With
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try

    End Sub

    Protected Overrides Sub InitAddNewRow(ByVal oRow As System.Data.DataRow)
        With oRow
            .Item("MaLoaiTien") = ""
            .Item("TenLoaiTien") = ""
        End With
    End Sub

    Protected Overrides Function DeleteDictionary() As Boolean
        oPrLoaiTien.SoLoaiTien = iValue
        oLoaiTien.DeleteLoaiTien(sConn, oPrLoaiTien)
    End Function

    Private Sub grdList_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grdList.MouseClick
        Try
            iValue = grdList.ActiveRow.Cells(TablePrimaryKey).Value
        Catch ex As Exception
        End Try
    End Sub

End Class
